package com.alphacsp.theedge2012.ui.activities;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TabHost;
import android.widget.TextView;
import com.alphacsp.theedge2012.R;

/**
 * Created by IntelliJ IDEA.
 * User: Gilad
 * Date: 23/10/10
 * Time: 01:18
 */
public class SessionDetailsActivity extends TabActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.session_detail_activity);
        final String sessionTopic = getIntent().getStringExtra("sessionTopic");
        final String sessionPresenter = getIntent().getStringExtra("sessionPresenter");
        final String sessionAbstract = getIntent().getStringExtra("sessionAbstract");

        final TabHost host = getTabHost();
        host.addTab(host.newTabSpec("Summary").setIndicator(buildIndicator("Summary")).setContent(R.id.session_abstract_tab));

        final TextView sessionTopicTextView = (TextView) findViewById(R.id.session_title);
        final TextView sessionPresenterTextView = (TextView) findViewById(R.id.session_subtitle);
        final TextView sessionAbstractTextView = (TextView) findViewById(R.id.session_abstract_tab_abstract);
        sessionTopicTextView.setText(sessionTopic);
        sessionPresenterTextView.setText(sessionPresenter);
        sessionAbstractTextView.setText(sessionAbstract);

        Intent intent = new Intent(SessionDetailsActivity.this, SessionsActivity.class);
        intent.putExtra("parallelQuery", sessionTopic);
        host.addTab(host.newTabSpec("In Parallel").setIndicator(buildIndicator("In Parallel")).setContent(intent));

    }

    private View buildIndicator(String text) {
        final TextView indicator = (TextView) getLayoutInflater().inflate(R.layout.tab_indicator, getTabWidget(), false);
        indicator.setText(text);
        return indicator;
    }

    public void onHomeClick(View view) {
        final Intent intent = new Intent(getApplicationContext(), HomeActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
    }

    @SuppressWarnings({"UnusedDeclaration"})
    public void onSearchClick(View v) {
        onSearchRequested();
    }
}
